﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;

public partial class Admin_Admin_AdsClickRecorde : Admin, IRequiresSessionState
{
    private Pagination _pagehander;
    protected string wherestr = "";
    protected string headlink = "";
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected Pagination m_pagehander
    {
        get
        {
            Pagination pagehander;
            if (this._pagehander == null)
            {
                this._pagehander = new Pagination();
                this._pagehander.SQL_JoinField = "UserID";
                this._pagehander.SQL_JoinField2 = "UserID";
                this._pagehander.SQL_LeftJoinTable = "HL_User";
                this._pagehander.SQL_LeftJoinField = "UserName";
                this._pagehander.P_Object = "记录";
                pagehander = this._pagehander;
            }
            else
            {
                pagehander = this._pagehander;
            }
            return pagehander;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.IsPostBack)
        {
            this.BindList();
        }
    }
    protected void BindList()
    {
        int num = Fetch.GetID("page");
        if (num == 0)
        {
            num = 1;
        }
        this.Questing();
        int pageSize = this.GridView1.PageSize;
        this.GridView1.DataSource = this.m_pagehander.GetDataTable("HL_AdsClickRecorde", num, pageSize, "ID", this.wherestr, "", this.conn, null);
        this.GridView1.DataBind();
        this.PagePanel.Text = this.m_pagehander.ShowPagePanel();
    }
    protected void Questing()
    {
        string text = Fetch.Get("time");
        if (text != string.Empty)
        {
            this.TxtInputTime.Text = text;
        }
        else
        {
            text = this.TxtInputTime.Text;
        }
        if (text != string.Empty)
        {
            this.wherestr = this.wherestr + "and DateDiff(s,'" + text + "',CreateTime)>=0 ";
            this.headlink = this.headlink + "&time=" + base.Server.UrlEncode(text);
        }
        string text2 = Fetch.Get("IP");
        if (text2 != string.Empty)
        {
            this.TxtIP.Text = text2;
        }
        else
        {
            text2 = this.TxtIP.Text;
        }
        if (text2 != string.Empty)
        {
            this.wherestr = this.wherestr + "and ComeIP='" + text2 + "' ";
            this.headlink = this.headlink + "&IP=" + base.Server.UrlEncode(text2);
        }
        string text3 = Fetch.Get("un");
        if (text3 != string.Empty)
        {
            this.TxtUserName.Text = text3;
        }
        else
        {
            text3 = this.TxtUserName.Text;
        }
        if (text3 != string.Empty)
        {
            this.wherestr = this.wherestr + "and HL_User.UserName Like '%" + text3 + "%' ";
            this.headlink = this.headlink + "&un=" + base.Server.UrlEncode(text3);
        }
        if (this.wherestr != string.Empty)
        {
            this.wherestr = "and" + this.wherestr;
            this.wherestr = this.wherestr.Replace("andand", "where");
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
    }
    protected void DeleteSelect(object sender, EventArgs e)
    {
        string text = Fetch.Post("IDS");
        if (Text.CheckNumList(text, ','))
        {
            this.conn.Execute("Delete From [HL_AdsClickRecorde] Where ID in(" + text + ")");
            this.BindList();
        }
    }
    protected void DeleteAll(object sender, EventArgs e)
    {
        if (this.TextBox1.Text != "")
        {
            if (Text.IsNumber(this.TextBox1.Text))
            {
                int num = Convert.ToInt32(this.TextBox1.Text);
                this.conn.Execute(string.Concat(new object[]
				{
					"Delete From [HL_AdsClickRecorde] Where DateDiff(dd,CreateTime,'",
					DateTime.Now,
					"')>=",
					num
				}));
                this.WriteSuccessMsg("", Language.GetAdminMsg("Common/DeleteSuccess"), "");
            }
        }
    }
    protected void OnSelect(object sender, EventArgs e)
    {
        this.BindList();
    }
}
